﻿using LIZTS.TODOS.Common.Models;
using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LIZTS.TODOS.ViewModels
{
    public class TodoViewModel : BindableBase
    {
        private ObservableCollection<TodoDto> todos;
        public DelegateCommand AddCommand { get; private set; }
        private bool isRightDrawerOpen;

        public bool IsRightDrawerOpen
        {
            get { return isRightDrawerOpen; } 
            set 
            {  
                if (isRightDrawerOpen != value) 
                {
                    isRightDrawerOpen = value;
                    RaisePropertyChanged();
                } 
            }
        }


        public ObservableCollection<TodoDto> Todos
        {
            get { return todos; }
            set
            {
                todos = value;
                RaisePropertyChanged();
            }
        }

        public TodoViewModel()
        {
            Todos = new ObservableCollection<TodoDto>();
            AddCommand = new DelegateCommand(AddTodo);
            MockData();
        }

        private void AddTodo()
        {
            IsRightDrawerOpen = true;
        }

        private void MockData()
        {
            for (int i = 0; i < 20; i++)
            {
                Todos.Add(new TodoDto() { Title = "TODO: " + i, Content = "make it possible" });
            }
        }
    }
}
